#include<iostream>
#include<string.h>
using std::cout;
using std::endl;
class Point
{
public:
   static Point* Getinstance(const char*p=nullptr)
    {

        if(_p==nullptr)
        {
             _p=new Point(p);
        }
        return _p;
    }
   void print()
   {
       cout<<_brand<<endl;
   }
private:
    Point(const char*p)
        :_brand(new char[strlen(p)+1]())
    {
        strcpy(_brand,p);
    }
    ~Point()
    {
        if(_brand)
        {
            cout<<"xigou"<<endl;
            delete []_brand;
            _brand=nullptr;
        }
    }
    friend
        class AutoRelease;
private:
    char *_brand;
static    Point* _p;
};
Point* Point::_p=nullptr;
class AutoRelease
{
public: 
    AutoRelease( Point* p)
        :_p(p)
    {
    };
    ~AutoRelease()
    {
        delete _p;
        _p=nullptr;
    }
private:
    Point* _p;
};

int main()
{
    AutoRelease p(Point::Getinstance("hellO"));
    Point::Getinstance()->print();
}
